Critical bug fix: Fix cluster-mode TLS disabled client to properly take received IPs when DNS is expanded #173
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug Description
This bug affects clusters in non-TLS setups that use a DNS endpoint storing multiple addresses, such as the cluster discovery endpoint in ElastiCache/MemoryDB.
Issue
When expanding a DNS endpoint from the initial nodes, we store the
socket_address
received from the expansion. However, in non-TCP connections, we haven't used the receivedsocket_address
. Instead, we re-resolved the original DNS entry when creating the actual connection. This caused a faulty mapping between the node address and the actual connection.Example Scenario
Consider the endpoint
cluster.dns.endpoint
expanded to IP1, IP2, and IP3. Previously, all nodes were mapped to a connection with the first address resolved fromcluster.dns.endpoint
. If a DNS lookup forcluster.dns.endpoint
returns the order [IP1, IP2, IP3], the connection map would be:As a result, requests routed to IP2 and IP3 were actually sent to IP1, leading to MOVED errors.
Fix
This fix modifies the
connect_simple
function to use the providedsocket_address
, if available, ensuring that connections are made to the addresses used as keys in the connection map. This adjustment aligns the non-TCP connection behavior with that of the TcpTls connection.Follow-Up
We should mock a DNS entry or the
dnslookup
function and add relevant tests to validate this fix.